#include "ClientSocket.h"
#include "SocketException.h"
#include <iostream>
#include <fstream>
#include <string>
#include <time.h> 

int main ( int argc, int argv[] )
{
	int error=0,total=0;
	std::ifstream data("/home/nick/桌面/title_day1000.txt");
    std::string buf;
    long whole=0;
    long now;
    while(data) {
//sleep(1);
        if(getline(data,buf)) {
			total++;
              try
    {

      ClientSocket client_socket ( "192.168.1.3", 30000 );

      std::string reply;

      try
	{
		
	  client_socket << buf;
	  now=clock();
	  client_socket >> reply;
	  whole+=clock()-now;
	}
      catch ( SocketException& ) {}
      if (reply=="error")
		;
		else
		std::cout << reply << std::endl;

    }
  catch ( SocketException& e )
    {
      std::cout << e.description() << "\n";
      error++;
    }
            }
        }
    data.close( );

std::cout<<"error:"<<error<<"    total:"<<total<<"    rate"<<error*1.0/total<<std::endl;
std::cout<<whole<<"    "<<whole*1.0/(total-error)/CLOCKS_PER_SEC<<std::endl;
  return 0;
}
